package com.xnf.behavior.controller.v1;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xnf.api.behavior.ApUnlikesBehaviorControllerApi;
import com.xnf.behavior.service.ApUnlikesBehaviorService;
import com.xnf.model.behavior.dtos.UnLikesBehaviorDto;
import com.xnf.model.behavior.pojos.ApUnlikesBehavior;
import com.xnf.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by xnf on 2022/3/8.
 */

@RestController
@RequestMapping("/api/v1")
public class ApUnlikesBehaviorController implements ApUnlikesBehaviorControllerApi{

    @Autowired
    private ApUnlikesBehaviorService apUnlikesBehaviorService;

    @PostMapping("/unlike_behavior")
    @Override
    public ResponseResult unlike(@RequestBody UnLikesBehaviorDto dto) {
        return apUnlikesBehaviorService.unlike(dto);
    }

    @GetMapping("/un_likes_behavior/one")
    @Override
    public ApUnlikesBehavior findUnLikeByArticleIdAndEntryId(@RequestParam("entryId") Integer entryId, @RequestParam("articleId") Long articleId) {
        return apUnlikesBehaviorService.getOne(Wrappers.<ApUnlikesBehavior>lambdaQuery().eq(ApUnlikesBehavior::getArticleId, articleId)
                .eq(ApUnlikesBehavior::getEntryId, entryId));
    }
}
